/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
 * PARTICULAR PURPOSE.
 * ***************************************************************************/



#if !defined(AFX_PGLMAPZ_H__9EF2A9DB_774D_4001_99FD_B4C7219CE7F3__INCLUDED_)
#define AFX_PGLMAPZ_H__9EF2A9DB_774D_4001_99FD_B4C7219CE7F3__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <pgl/core/PGLMap.h>
#include <pgl/core/PGLUtility.h>

/*! \brief A height map on evenly spaced lattice.

\ingroup PGLMapGroup
*/
class PGLCORE_EXT_CLASS CPGLMapZ : public CPGLMap  
{
PGL_DECLARE_DYNCREATE(CPGLMapZ);
public:
	typedef contour::TField<float> Field;
	//! \name Constructors
	//@{
	CPGLMapZ();
	//! copy constructor
	CPGLMapZ(const CPGLMapZ& l):m_pField(NULL){*this=l;};
	//! assignment constructor
	CPGLMapZ& operator = (const CPGLMapZ& l);
	//! destructor
	~CPGLMapZ();
	//@}

	//! \name GUI
	//@{
	//! adds context menu items...
	virtual void AddContextMenuItems(CMenu* pMenu);
	//! adds the line property page to the property sheet dialog.
	virtual void AddPropertyPage(CPropertySheet *pPropSheet);
	//@}


	virtual void PlotGfx(gfxinterface::CGfxInterface& gfx);

	//! \name Data manipulation
	//@{
	//! returns minimum and maximum value of Z
	void GetMinMax(double& dMin, double& dMax) const;
	//@}

	//! \name Field
	//@{
	//! return a pointer to the current field
	Field* GetField()							{	return m_pField;};
	/*! Sets the current field
	\param pField a field derived from Field,
	\param bHandleCleaning true if the field will be delete by the map (default behavior)
	*/
	void SetField(Field* pField,bool bHandleCleaning = true);
	//! Deletes field if needed see SetField
	void CleanField();
	//@}

	//! \name Colormap
	//@{
	/*! \brief returns colormap type

	Returns the type of color maps.
	\sa PGL_COLORMAP
	*/
	CPGLUtility::EColorMap GetColorMap() const	{	return m_eCMap;};
	//! set the type of colormap
	void SetColorMap(CPGLUtility::EColorMap eCMap){	m_eCMap=eCMap;};
	//@}

	//! Serialize functions
	//@{
	//! Serialiation to XML
	void SerializeXML(CPGLArchive& ar);

	//! Debuggin functions
	#ifdef _DEBUG
		//! MFC Dump
	    virtual void Dump( CDumpContext& dc ) const;
		//! MFC AssertValid
	    virtual void AssertValid() const;   
	#endif
	//@}
protected:
    //! \name Attributes
    //@{
	//! a field object
	Field* m_pField;
	//! cleaning bit
	bool m_bDeleteField;
	//! color map
	CPGLUtility::EColorMap m_eCMap;
	//@}
private:
    // \name Private Attributes
    //@{ 
	//! \f$\min z(x,y)\f$
	double m_dMin;
	//! \f$\max z(x,y)\f$
	double m_dMax;
	//@}
};

#ifndef PGL_DECLARE_SMARTPTR
#define PGL_DECLARE_SMARTPTR( className ) \
   typedef boost::shared_ptr< className > className ##Ptr;\
   typedef boost::weak_ptr< className > className ##WkPtr; \
   typedef boost::static_ptr< className > className ##StPtr;
#endif

PGL_DECLARE_SMARTPTR( CPGLMapZ );

#endif // !defined(AFX_PGLMAPZ_H__9EF2A9DB_774D_4001_99FD_B4C7219CE7F3__INCLUDED_)
